package lzyc.pointsManagement.business.honor.controller;

import lzyc.pointsManagement.business.honor.domain.HonorInfo;
import lzyc.pointsManagement.business.honor.service.HonorInfoService;
import lzyc.pointsManagement.common.core.controller.BaseController;
import lzyc.pointsManagement.common.core.domain.AjaxResult;
import lzyc.pointsManagement.common.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HonorInfo)表控制层
 *
 * @author yangyang
 * @since 2024-03-10 17:03:54
 */
@RestController
@RequestMapping("/api/v1/honor")
public class HonorInfoController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private HonorInfoService honorInfoService;

    /**
     *
     * @param honorInfo
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HonorInfo honorInfo) {
        startPage();
        List<HonorInfo> list = honorInfoService.queryAll(honorInfo);
        return getDataTable(list);
    }

    /**
     * 获取列表
     *
     * @param honorID
     * @return
     */
    @PostMapping("/detail")
    @ResponseBody
    public AjaxResult detail(String honorID) {
        return success(honorInfoService.queryById(honorID));
    }

    /**
     * 新增
     * 
     * @param honorInfo
     * @return
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult add(@RequestBody HonorInfo honorInfo) {
        return toAjax(honorInfoService.insert(honorInfo));
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @PostMapping("/delete")
    @ResponseBody
    public AjaxResult delete(String ids) {
        return toAjax(honorInfoService.deleteById(ids));
    }

    /**
     * 批量评审荣誉信息
     * 
     * @param ids
     * @param status
     * @return
     */
    @PostMapping("/review")
    @ResponseBody
    public AjaxResult review(String ids, String status) {
        return toAjax(honorInfoService.approvalHonorInfos(ids, status));
    }

}